﻿/*!	@file	r_gui_event.h
	@brief	GUIイベントクラス
Copyright (c) 2010 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _R_GUI_EVENT_H_
#define _R_GUI_EVENT_H_

#include "r_gui_def.h"

namespace r{
	namespace gui{
		class Widget;

		class Event
		{
		public:
			Event();
			~Event();
		public:
			// システム呼び出し
			//! 更新
			/*!
			*/
			void					update();
		public:
			//! ドラッグ開始イベントの設定
			/*!
			*/
			void					setLMBDrag ( Widget* widget );
			void					setLMBDrop ( Widget* widget );
			//! キーボードフォーカス取得
			void					setKeyboardFocus ( Widget* widget );
			//! フォーカス送り
			/*! (現在はダミー)
			*/
			void					moveKeyboardFocus();
		public:
			//! マウス位置を取得
			/*!
			*/
			void					getCurPos ( r_si32& x, r_si32& y ) const;
			//! マウスのクリック状況を取得
			r_bool					getLMBHover() const;
			r_bool					getLMBClick() const;
			r_bool					getLMBDClick() const;
			r_bool					getLMBPress() const;
			r_bool					getLMBRelease() const;
			r_bool					getRMBHover() const;
			r_bool					getRMBClick() const;
			r_bool					getRMBDClick() const;
			r_bool					getRMBPress() const;
			r_bool					getRMBRelease() const;
			//! ドラッグGUIの取得
			/*!
			*/
			Widget*			getLMBDragWidget() const;
			Widget*			getLMBOldDragWidget() const;
			//! ドロップGUIの取得
			/*!
			*/
			Widget*			getLMBDropWidget() const;
			//! ドラッグ開始位置を取得
			/*!
			*/
			void					getDragPos ( r_si32& x, r_si32& y ) const;
			//! キーボd－フォーカスGUIの取得
			/*!
			*/
			Widget*			getKeyboardFocusWidget() const;
			Widget*			getOldKeyboardFocusWidget() const;
		protected:
		private:
			// マウスキー
			r_bool					LMBPressed;
			r_bool					RMBPressed;
			r_bool					LMBPushed;
			r_bool					RMBPushed;
			r_bool					LMBReleased;
			r_bool					RMBReleased;
			// マウスボタンダブルクリックカウント
			r_ui32					LMBDoubleClick;
			r_bool					LMBDoubleClicked;
			r_ui32					RMBDoubleClick;
			r_bool					RMBDoubleClicked;
			//! ドラッグ開始点
			r_si32					dragBeginX;
			r_si32					dragBeginY;
			//! 現在の位置
			r_si32					curX;
			r_si32					curY;
			//! ドラッグ対象GUI
			Widget*			LMBDragWidget;
			Widget*			LMBDropWidget;
			Widget*			LMBOldDragWidget;
			//! キーボードフォーカスGUI
			Widget*			KeyFocusWidget;
			Widget*			OldKeyFocusWidget;
		};
	}
}

#endif // _R_GUI_EVENT_H_
